package com.example.work_study_system.web.controller;


import com.example.work_study_system.model.domain.Administrator;
import com.example.work_study_system.service.AdministratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/administrator")
public class AdministratorController {
    @Autowired
    private AdministratorService administratorService;

    @GetMapping("/list")
    public List<Administrator> list() {
        return administratorService.list();
    }

    @GetMapping("/{id}")
    public Administrator getById(@PathVariable Integer id) {
        return administratorService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Administrator administrator) {
        return administratorService.save(administrator);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Administrator administrator) {
        return administratorService.updateById(administrator);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id) {
        return administratorService.removeById(id);
    }
} 